package com.baishancloud.log.directories

import com.baishancloud.log.common.util.DimMessageFetch
import org.slf4j.{Logger, LoggerFactory}

import scala.collection.mutable


class FetchLatestDomainId

/**
 *
 * 获取最新域名信息
 *
 * @author ziqiang.wang
 * @date 2021-11-07 19:11
 * */
object FetchLatestDomainId {

  val LOGGER: Logger = LoggerFactory.getLogger(classOf[FetchLatestDomainId])


  /**
   * 获取最新域名信息
   */
  def core(domainId: mutable.Map[String, Int]): Unit = {
    val accountDomainId: mutable.Map[String, Int] = mutable.Map[String, Int]()
    DimMessageFetch.fetchAccountDomainId("maocloud-catlog", accountDomainId)
    val domainIdAll: mutable.Map[String, Int] = mutable.Map[String, Int]()
    DimMessageFetch.fetchDomainIdAll(domainIdAll)
    accountDomainId.foreach(x => domainId.put(x._1, x._2))
    StreamingDirectoriesAggregate.levelOneDomains.foreach(x => {
      if (domainIdAll.contains(x)) {
        domainId.put(x, domainIdAll(x))
      }
    })

  }

}
